package com.zmm.study.mes.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmm.study.mes.dao.SpTableManagerDao;
import com.zmm.study.mes.service.SpTableManagerService;
import com.zmm.study.mes.entity.basedata.SpTableManager;
import com.zmm.study.mes.entity.basedata.SpTableManagerItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * description
 * name SpTableManagerServiceImpl
 *
 * @author Zebulon
 * @date by 2022-05-05 21:31:30
 */
@Service
public class SpTableManagerServiceImpl extends ServiceImpl<SpTableManagerDao, SpTableManager> implements SpTableManagerService {
    @Autowired
    private SpTableManagerDao spTableManagerDao;

    /**
     * 查询表对应的字段
     *
     * @param req 表信息
     * @return 字段信息
     */
    @Override
    public List<SpTableManagerItem> queryTableFieldByName(SpTableManager req) throws Exception {
        List<SpTableManagerItem> spTableManagerItems = spTableManagerDao.queryTableFieldByName(req);
        if (CollectionUtil.isEmpty(spTableManagerItems)) {
            throw new Exception("表不存在数据库中。请核对");
        }
        return spTableManagerItems;
    }
}
